/*
stl_debug.h: A debugging library for STL, headers part, headers part.
    Copyright (C) 2009  Daniel Gutson, FuDePAN

    This file is part of stl_debug.

    stl_debug is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    stl_debug is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with stl_debug.  If not, see <http://www.gnu.org/licenses/>.
    
    Example file.
*/

#include "stl_debug.h"
#include "stl_debug_impl.h" /* This has to be included in only one source file */

#include <vector>
#include <map>
#include <string>

using namespace std;

class MyClass
{
STL_DEBUG_PRIVATE:
    struct MyStruct
    {
        int a;
        int b;
    };

private:
    vector<MyStruct> vec;

public:
    MyClass()
    {
        MyStruct s;

        s.a = 1;
        s.b = 2;
        vec.push_back(s);
        vec.push_back(s);
    }

    int sum() const
    {
        int ret = 0;
        for( vector<MyStruct>::const_iterator it = vec.begin(); it != vec.end(); ++it)
            ret += it->a;
        return ret;
    }
};

#ifdef STL_DEBUG_ENABLE
DECLARE_STL_TO_COUT(MyClass::MyStruct)
{
    /* 'p' is the parameter */
    stl_print(p.a, false);
    stl_print(" ", false);
    stl_print(p.b, false);
}
#endif

STL_DEBUG_REGISTER_VECTOR(MyClass::MyStruct);

int main()
{
    MyClass mc;
    
    return mc.sum();
}

/******************* Instructions ******************
    Compile this file as:
    g++ example.cpp -o example -g -DSTL_DEBUG_ENABLE

    Then, during debugging (gdb example), do:
    break main
    run
    next
    call stl_print(mc.vec)
    step
    next
    next
    call stl_print(it)
****************************************************/
